const app = getApp()
Page({

       
  data: {
          catelist:["男装","女装","零食","家电","床上用品","家具"],
          bannerlist:[{
            url:"../../images/banner1.jpg"
          },{
            url:"../../images/banner2.jpg"
          },{
            url:"../../images/banner3.jpg"
          }
        ],
        danmulist:[
          {
            text:"网院",
            color:"#ff0000",
            time:10
          },
        {
          text:"电大",
          color:"#E64E69",
          time:30
        }],
latitude:"",
longitude:""
  },

  
  onLoad(){
          
  },
  saveUserInfo:function(){
    //同步缓存
    var data = {"name":"李日晖","student_id":"201965110458"}
wx.setStorageSync('userinfo', data)
wx.setStorage({
  data: {"sex":男,"age":21}
,  key: 'studentinfo',
})
  },
  getUserInfo:function(){
    //同步获取缓存数据
 var studentinfo = wx.getStorageSync('studentinfo');
 console.log(studentinfo);
 wx.getStorage({
   key: 'usrinfo',
   success(res){
     console.log(res);
   }
 })
 
 //获取小程序中所有的缓存信息 （key）
 wx.getStorageInfo({
   success: (option) => {
     console.log(option)
   },
 })
  },
  removeUserInfo:function(){
//异步移除
wx.removeStorage({
  key: 'userinfo',
})
wx.removeStorageSync('studentinfo')
  },
  getLocal:function(){
    var then = this;
wx.getLocation({
  type:"gcjo2",
  success(res){
    then.setData({
latitude:res.latitude,
longitude:res.longitude
    })
   
  }
})
  },
  selectImage:function(){
    wx.chooseImage({
      sourceType:['camera'],
      count: 1,
      success(res){
        console.log(res);
        wx.previewImage({
          urls: [res.tempFilePaths[0]],
        })
        wx.getImageInfo({
          src:// '../../images/banner1.jpg',
           [res.tempFilePaths[0]],
          success(res){
            console.log(res)
          }
        })
      }
    })
  },
  saveImage:function(){
wx.saveImageToPhotosAlbum({
  filePath: 'http://tmp/1mr5IB4xo8wI6005ecfdeca19f2e55afd12e27685782.jpg',
})
  },
 
  openMap:function(){
    var then = this;
wx.openLocation({
  latitude: then.data.latitude,
  longitude: then.data.longitude,
  name:"湖南开放大学终教楼1104",
  address:"湖南省长沙市天心区青园路168号1104"
})
  },
  selectLocal:function(){
    var then = this;
wx.chooseLocation({
  latitude: then.data.latitude,
  longitude: then.data.longitude
})
  },
  call:function(){
    wx.makePhoneCall({
      phoneNumber: '123456789',
    })
  },
  scanCode:function(){
    wx.scanCode({
      onlyFromCamera: true,
      success(res){
        console.log(res)
      }
    })
  },
  checkboxChange:function(e){
    var then = this;
    var likestr = "";
    for (let index = 0; index < e.detail.value.length; index++) {
 likestr = likestr+ e.detail.value[index];
    }
    then.setData({
      likes:likestr
    })
console.log(e)
console.log(e.detail.value[0])
  },
})   

  